<?php


namespace api\channel\jutuike;


use api\channel\ExtendChannleBase;
use app\model\BaseSupplier;
use think\Exception;

abstract class Base extends ExtendChannleBase
{


    public $baseUrl = 'http://api.jutuike.com';

    public function __construct($serv_type = PRODUCT_COUPON_SERV)
    {
        $jutuikeInfo = BaseSupplier::where('code', BaseSupplier::CODE_JUTUIKE)
            ->where('serv_type',$serv_type)
            ->find();

        if (!$jutuikeInfo) {
            throw new Exception('不存在聚推客配置信息');
        }
        if (empty($jutuikeInfo->api_config['apikey'])) {
            throw new Exception('缺少配置信息');
        }

        $this->supplierInfo = $jutuikeInfo;

        $this->apikey = $jutuikeInfo->api_config['apikey'];
    }



    /**
     * 返回供应商id
     */
    public function getId(): int
    {
        return $this->supplierInfo['id'];
    }

    /**
     * 订单拉取
     * @return mixed
     */
    abstract public function orders($params);

}